<?php
/**
* Base class for page templates. All template classes extend from this class.
*
* Copyright (c) 2009 James Gauld <james@jamesgauld.net>
* This file is part of Scribble.
* @license http://www.scribblecms.co.uk/license.txt
*
* @package Scribble
*/
abstract class ScribbleTemplate {

	/**
	* Type constants.
	*
	* A template must be one of these types:
	* OUTER - Provides the whole document from <html>..</html>
	* INNER - Provides content that gets injected into an OUTER template
	*
	* @constants int
	*/
	const TYPE_INNER = 0;
	const TYPE_OUTER = 1;

	/**
	* Absolute path to this template's folder.
	*
	* @var string
	*/
	private $baseFolder;

	/**
	* Absolute URL to this template's folder.
	*
	* @var string
	*/
	private $baseUrl;

	/**
	* Name of the folder containing this template.
	*
	* @var string
	*/
	public $name;

	/**
	* Constructor.
	*
	* @param string Name of the template
	* @return ScribbleTemplate
	*/
	public function __construct($name) {
		$this->name = $name;
	}

	/**
	* Return this template's base folder path.
	*
	* @return string
	*/
	final public function getBaseFolder() {
		return "{$this->baseFolder}/{$this->name}";
	}

	/**
	* Return this template's base folder URL.
	*
	* @return string
	*/
	final public function getBaseUrl() {
		return "{$this->baseUrl}/{$this->name}";
	}

	/**
	* Returns the "General" default category.
	*
	* @return string
	*/
	public function getCategory() {
		return "General";
	}

	/**
	* Return a longer description of this template to aid content authors.
	*
	* @return string
	*/
	public function getLongDescription() {
		return "";
	}

	/**
	* Return a short description of this template to aid content authors.
	*
	* @return string
	*/
	public function getShortDescription() {
		return "";
	}

	/**
	* A placeholder for the saveHandler() method. Override this in your template
	* class if you need it.
	*
	* @param PageModel
	* @param bool
	* @return void
	*/
	public function saveHandler(PageModel $page, $isSuccess) {
	}

	/**
	* Set this template's base folder path.
	*
	* @param string Absolute folder path
	* @return void
	*/
	final public function setBaseFolder($folder) {
		$this->baseFolder = $folder;
	}

	/**
	* Set this template's base URL path.
	*
	* @param string Absolute URL path
	* @return void
	*/
	final public function setBaseUrl($url) {
		$this->baseUrl = $url;
	}
}
?>